# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=codeql
pkgver=2.22.4
pkgrel=1
epoch=1
groups=('blackarch' 'blackarch-automation' 'blackarch-code-audit')
pkgdesc='The CLI tool for GitHub CodeQL'
arch=('x86_64')
url='https://github.com/codeql'
license=('custom')
depends=('java-runtime-headless' 'bash')
source=("$pkgname-v$pkgver.zip::https://github.com/github/codeql-cli-binaries/releases/download/v$pkgver/$pkgname-linux64.zip")
sha512sums=('61cd0345d2d7c436a1b829b825f4627e9297a6c48e08a820dcf345c9c6cda6ae905ba7806acdab46385434df50d4a95211a71e8b6ae1ccf15f998d888071b9a7')

prepare() {
  ln -sf "$pkgname/tools/linux64/lib64trace.so" \
    "$pkgname/tools/linux64/libtrace.so"
}

package() {
  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 "$pkgname/LICENSE.md" \
    "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  cp -a $pkgname "$pkgdir/usr/share/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec /usr/share/$pkgname/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

